//===--- BuiltinTypes.def - Compiler declaration metaprogramming --*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This file defines macros used for macro-metaprogramming with compiler-known
// built-in types.
//
//===----------------------------------------------------------------------===//

#ifndef BUILTIN_TYPE
#  define BUILTIN_TYPE(Symbol, Name)
#endif

#ifndef BUILTIN_POINTER_TYPE
#  define BUILTIN_POINTER_TYPE(Symbol, Name) BUILTIN_TYPE(Symbol, Name)
#endif

#define VECTOR_BUILTIN_SYMBOL_NAME(ElementSymbol, Width) \
  ElementSymbol##Bv##Width##_

#ifndef BUILTIN_VECTOR_TYPE
#  define BUILTIN_VECTOR_TYPE(ElementSymbol, ElementName, Width) \
     BUILTIN_TYPE(ElementSymbol##Bv##Width##_,                   \
                  "Builtin.Vec" #Width "x" #ElementName)
#endif

BUILTIN_TYPE(Bi1_, "Builtin.Int1")
BUILTIN_TYPE(Bi7_, "Builtin.Int7")
BUILTIN_TYPE(Bi8_, "Builtin.Int8")
BUILTIN_TYPE(Bi16_, "Builtin.Int16")
BUILTIN_TYPE(Bi32_, "Builtin.Int32")
BUILTIN_TYPE(Bi63_, "Builtin.Int63")
BUILTIN_TYPE(Bi64_, "Builtin.Int64")
BUILTIN_TYPE(Bi128_, "Builtin.Int128")
BUILTIN_TYPE(Bi256_, "Builtin.Int256")
BUILTIN_TYPE(Bi512_, "Builtin.Int512")

BUILTIN_TYPE(Bw, "Builtin.Word")

BUILTIN_TYPE(Bf16_, "Builtin.FPIEEE16")
BUILTIN_TYPE(Bf32_, "Builtin.FPIEEE32")
BUILTIN_TYPE(Bf64_, "Builtin.FPIEEE64")
BUILTIN_TYPE(Bf80_, "Builtin.FPIEEE80")
BUILTIN_TYPE(Bf128_, "Builtin.FPIEEE128")

BUILTIN_POINTER_TYPE(Bo, "Builtin.NativeObject")
BUILTIN_POINTER_TYPE(Bb, "Builtin.BridgeObject")
BUILTIN_POINTER_TYPE(Bp, "Builtin.RawPointer")
BUILTIN_TYPE(BB, "Builtin.UnsafeValueBuffer")

// No longer used in the compiler as an AST type, but still used for fields 
// shaped like AnyObject (normal mangling yXl).
BUILTIN_POINTER_TYPE(BO, "Builtin.UnknownObject")

// Int8 vector types
BUILTIN_VECTOR_TYPE(Bi8_, Int8, 2)
BUILTIN_VECTOR_TYPE(Bi8_, Int8, 3)
BUILTIN_VECTOR_TYPE(Bi8_, Int8, 4)
BUILTIN_VECTOR_TYPE(Bi8_, Int8, 8)
BUILTIN_VECTOR_TYPE(Bi8_, Int8, 16)
BUILTIN_VECTOR_TYPE(Bi8_, Int8, 32)
BUILTIN_VECTOR_TYPE(Bi8_, Int8, 64)

// Int16 vector types
BUILTIN_VECTOR_TYPE(Bi16_, Int16, 2)
BUILTIN_VECTOR_TYPE(Bi16_, Int16, 3)
BUILTIN_VECTOR_TYPE(Bi16_, Int16, 4)
BUILTIN_VECTOR_TYPE(Bi16_, Int16, 8)
BUILTIN_VECTOR_TYPE(Bi16_, Int16, 16)
BUILTIN_VECTOR_TYPE(Bi16_, Int16, 32)
BUILTIN_VECTOR_TYPE(Bi16_, Int16, 64)

// Int32 vector types
BUILTIN_VECTOR_TYPE(Bi32_, Int32, 2)
BUILTIN_VECTOR_TYPE(Bi32_, Int32, 3)
BUILTIN_VECTOR_TYPE(Bi32_, Int32, 4)
BUILTIN_VECTOR_TYPE(Bi32_, Int32, 8)
BUILTIN_VECTOR_TYPE(Bi32_, Int32, 16)
BUILTIN_VECTOR_TYPE(Bi32_, Int32, 32)
BUILTIN_VECTOR_TYPE(Bi32_, Int32, 64)

// Int64 vector types
BUILTIN_VECTOR_TYPE(Bi64_, Int64, 2)
BUILTIN_VECTOR_TYPE(Bi64_, Int64, 3)
BUILTIN_VECTOR_TYPE(Bi64_, Int64, 4)
BUILTIN_VECTOR_TYPE(Bi64_, Int64, 8)
BUILTIN_VECTOR_TYPE(Bi64_, Int64, 16)
BUILTIN_VECTOR_TYPE(Bi64_, Int64, 32)
BUILTIN_VECTOR_TYPE(Bi64_, Int64, 64)

// Float32 vector types
BUILTIN_VECTOR_TYPE(Bf32_, FPIEEE32, 2)
BUILTIN_VECTOR_TYPE(Bf32_, FPIEEE32, 3)
BUILTIN_VECTOR_TYPE(Bf32_, FPIEEE32, 4)
BUILTIN_VECTOR_TYPE(Bf32_, FPIEEE32, 8)
BUILTIN_VECTOR_TYPE(Bf32_, FPIEEE32, 16)
BUILTIN_VECTOR_TYPE(Bf32_, FPIEEE32, 32)
BUILTIN_VECTOR_TYPE(Bf32_, FPIEEE32, 64)

// Float64 vector types
BUILTIN_VECTOR_TYPE(Bf64_, FPIEEE64, 2)
BUILTIN_VECTOR_TYPE(Bf64_, FPIEEE64, 3)
BUILTIN_VECTOR_TYPE(Bf64_, FPIEEE64, 4)
BUILTIN_VECTOR_TYPE(Bf64_, FPIEEE64, 8)
BUILTIN_VECTOR_TYPE(Bf64_, FPIEEE64, 16)
BUILTIN_VECTOR_TYPE(Bf64_, FPIEEE64, 32)
BUILTIN_VECTOR_TYPE(Bf64_, FPIEEE64, 64)

#undef BUILTIN_VECTOR_TYPE
#undef VECTOR_BUILTIN_SYMBOL_NAME
#undef BUILTIN_POINTER_TYPE
#undef BUILTIN_TYPE
